import React, { Component } from "react";
import { withRouter } from "react-router-dom";
import { Toast } from "antd-mobile";
import "./user.scss";
import youtou from '../../img/youtou.png'
class user extends Component {
  state = {
    name: "",
  };

  componentDidMount() {
    let locname = JSON.parse(localStorage.getItem("user"));
    // console.log(locname);
    this.setState({ name: locname });
  }
  handleLogin() {
    localStorage.removeItem("user");
    Toast.info("退出成功", 1);
    this.props.history.push("/login");
  }
  render() {
    return (
      <div className="Boxpusl">
        <div className="Heard">
          <i className="Matchstick_Men">
            <img
              src="//yanxuan.nosdn.127.net/8945ae63d940cc42406c3f67019c5cb6.png"
              alt=""
            />
          </i>
          <p className="Username">{this.state.name}</p>
          <b><img src={youtou} alt=""/></b>
        </div>
        <div className="Truncus"></div>
        <div className="Loginbtn">
          <div className="MainLogin" onClick={this.handleLogin.bind(this)}>
            退出登录
          </div>
        </div>
      </div>
    );
  }
}
export default withRouter(user);
